<?php
//function created (uses for checking all checkbox and confirm to delete selected item) which is in /js/custom_scripts.js
    echo $javascript->link('custom_scripts');
?>
<div id="tabs">
	<ul>
        <li  id="current"><?php echo $this->Html->link(__('Danh sách nhân viên', true), array('controller' => 'znvusers', 'action' => 'index',$id_dv)); ?> </li>
        <li><?php echo $this->Html->link(__('Thêm nhân viên', true), array('controller'=>'nhanviens','action' => 'add',$id_dv)); ?></li>
        <li><?php echo $this->Html->link(__('Sơ đồ tổ chức', true), array('controller'=>'thuocdvs','action' => 'tochuc')); ?></li>
	</ul>
	</ul>
</div>
<div class="znvusers">
<h2><?php __('Danh sách nhân viên đơn vị '.$tendv[0] ['donvis']['tendv']);?></h2>
<?php
	 echo $this->Form->create('Thuocdv',array('url'=>'adduser/'.$tendv[0] ['donvis']['id']));
     ?>


	<table cellpadding="0" cellspacing="0" id="tables">
	<tr>
           <th style="width: 10px;"><input type="checkbox" onclick="checkAll(this);" /></th>
		
			<th><?php echo 'STT';?></th>
			<th><?php echo 'Mã NV';?></th>
			<th><?php echo 'Chức danh';?></th>
			<th><?php echo 'Họ tên';?></th>
			<th><?php echo 'Số ĐT';?></th>
			<th><?php echo 'Email';?></th>
			<th><?php echo 'Địa chỉ';?></th>
           	<th><?php echo 'Trạng thái';?></th>
            <th><?php echo 'Tài khoản';?></th>
         
		
			<th class="actions"><?php __('Lựa chọn');?></th>
	</tr>
<?php
$i = 0;$k=1;
foreach ($znvusers as $znvuser):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
    <?php
        if(empty($znvuser['Znvuser']['user_id'])){
	        echo '<td width="3%"><input type="checkbox" value="'.$znvuser['Znvuser']['id'].'" 
                    name="data[Znvuser][checked][]" id="'.$k.'" ></td>';
            $k++;
         }
         else echo '<td></td>';
        ?>
		<td>
			<?php echo $i//echo $znvuser['Znvuser']['id']; ?>
		</td>
		<td>
			<?php echo $znvuser['Znvuser']['manv']; ?>
		</td>
	
		<td>
			<?php echo $znvuser['Znvuser']['chucdanh_id']; ?>
		</td>
		<td>
			<?php echo $znvuser['Znvuser']['tennv']; ?>
		</td>
		<td>
			<?php echo $znvuser['Znvuser']['sdt']; ?>
		</td>
		<td>
			<?php echo $znvuser['Znvuser']['email']; ?>
		</td>
		<td>
			<?php echo $znvuser['Znvuser']['diachi']; ?>
		</td>
	 <td><?php if($znvuser['Znvuser']['conlam']==1) echo 'Đang làm'; else 'Nghỉ việc';  ?>&nbsp;</td>
			<td>
			<?php if(empty($znvuser['Znvuser']['user_id']))
            	    echo $html->link(__('Tạo TK', true), array('controller'=>'users','action' => 'add', $znvuser['Znvuser']['id']));
                  else
                    echo $znvuser['User']['username'].'<br/> '.$html->link(__('Reset password', true), array('controller'=>'users','action' => 'reset', $znvuser['Znvuser']['user_id'],$id_dv));                     
            ?>
			
                     
		</td>
		<td class="actions">
			<?php // echo $html->link(__('View', true), array('action' => 'view', $znvuser['Znvuser']['id'])); ?>
			<?php echo $html->link(__('Sửa', true), array('controller'=>'nhanviens','action' => 'edit', $znvuser['Znvuser']['id'])); ?>
			<?php echo $html->link(__('Xóa', true), array('controller'=>'nhanviens','action' => 'delete', $znvuser['Znvuser']['id'],$id_dv), null, sprintf(__('Are you sure you want to delete # %s?', true), $znvuser['Znvuser']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
</div>
